package com.ruoyi.lwpq.util;

public class IdCardUtil {

    final int[] Weight = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2,
            1 }; // 加权因子
    final String[] Verifycode = { "1", "0", "X", "9", "8", "7", "6", "5", "4",
            "3", "2" }; // 校验码


    public String proIdCard15to18(String idCard) {
        int i, j, s = 0;
        String newidCard;
        newidCard = idCard;
        newidCard = newidCard.substring(0, 6) + "19"
                + newidCard.substring(6, idCard.length());
        for (i = 0; i < newidCard.length(); i++) {
                j = Integer.parseInt(newidCard.substring(i, i + 1)) * Weight[i];
            s = s + j;
        }
        s = s % 11;
        newidCard = newidCard + Verifycode[s];
        return newidCard;
    }
}
